package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ZxbPasswordMapper;
import com.ruoyi.system.domain.ZxbPassword;
import com.ruoyi.system.service.IZxbPasswordService;

import javax.crypto.KeyGenerator;

/**
 * 账户密码管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-10-11
 */
@Service
public class ZxbPasswordServiceImpl implements IZxbPasswordService 
{
    @Autowired
    private ZxbPasswordMapper zxbPasswordMapper;

    /**
     * 查询账户密码管理
     * 
     * @param pwdId 账户密码管理主键
     * @return 账户密码管理
     */
    @Override
    public ZxbPassword selectZxbPasswordByPwdId(Long pwdId)
    {
        return zxbPasswordMapper.selectZxbPasswordByPwdId(pwdId);
    }

    /**
     * 查询账户密码管理列表
     * 
     * @param zxbPassword 账户密码管理
     * @return 账户密码管理
     */
    @Override
    public List<ZxbPassword> selectZxbPasswordList(ZxbPassword zxbPassword)
    {
        return zxbPasswordMapper.selectZxbPasswordList(zxbPassword);
    }

    /**
     * 新增账户密码管理
     * 使用用户密码对 password进行加密
     * 
     * @param zxbPassword 账户密码管理
     * @return 结果
     */
    @Override
    public int insertZxbPassword(ZxbPassword zxbPassword)
    {
        zxbPassword.setCreateTime(DateUtils.getNowDate());
        String pwd = SecurityUtils.getLoginUser().getPassword();
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        return zxbPasswordMapper.insertZxbPassword(zxbPassword);
    }

    /**
     * 修改账户密码管理
     * 
     * @param zxbPassword 账户密码管理
     * @return 结果
     */
    @Override
    public int updateZxbPassword(ZxbPassword zxbPassword)
    {
        zxbPassword.setUpdateTime(DateUtils.getNowDate());
        return zxbPasswordMapper.updateZxbPassword(zxbPassword);
    }

    /**
     * 批量删除账户密码管理
     * 
     * @param pwdIds 需要删除的账户密码管理主键
     * @return 结果
     */
    @Override
    public int deleteZxbPasswordByPwdIds(Long[] pwdIds)
    {
        return zxbPasswordMapper.deleteZxbPasswordByPwdIds(pwdIds);
    }

    /**
     * 删除账户密码管理信息
     * 
     * @param pwdId 账户密码管理主键
     * @return 结果
     */
    @Override
    public int deleteZxbPasswordByPwdId(Long pwdId)
    {
        return zxbPasswordMapper.deleteZxbPasswordByPwdId(pwdId);
    }
}
